<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            检测模板列表
        </div>
    </header>

    <script id="chkTemplateTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="setChkTemplate('{{= it[index].code }}','{{= it[index].name }}','{{= it[index].chkTypeName }}','{{= it[index].mrlCode }}','{{= it[index].mrlName }}');">
            <div class="aui-media-list-item-inner">
                <div class="aui-list-item-inner ">
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            模板编码:{{= it[index].code }}
                        </div>
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        模板名称:{{= it[index].name }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        检测类型:{{= it[index].chkTypeName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        物料编码:{{= it[index].mrlCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        物料名称:{{= it[index].mrlName }}
                    </div>
                </div>
            </div>
        </li>
        {{~}}

    </script>

   <!--  <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form action="javascript:doSearch();">
                        <input type="search" placeholder="请输入物料编码" id="mrlCodeS">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4" onclick="doSearch()">搜索</div>
        </div>
    </div> -->
    <div class="aui-content" style="margin-top:50px;">
        <div class="aui-form" style="margin-top:15px;">
            <div class="aui-content aui-margin-b-15">
                <ul class="aui-list aui-form-list" >
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                           <div class="aui-list-item-label">工单号</div>
                            <div class="aui-list-item-input">
                                <input type="text" placeholder="请输入工单号" id="workOrder" value=""
                                onclick="getIdSelector();"/>
                            </div>
                        </div>
                    </li>
                    <li class="aui-list-item">
                        <div class="aui-list-item-inner">
                           <div class="aui-list-item-label">物料编码</div>
                            <div class="aui-list-item-input">
                                <input type="text" placeholder="请输入物料编码" id="mrlCodeS" value=""
                                onclick="getIdSelector();" />
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <div style="width:100%;margin-top:2%;"></div>
    <div class="aui-btn aui-btn-info aui-btn-block" onclick="doSearch()">查询</div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="chkTemplateList">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    var chkBillType = "";
    apiready = function() {
        chkBillType = api.pageParam.chkBillType;
        doSearch();
    };
     // 获取光标所在组件的id
     function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //查询检测模板
    function doSearch() {
        var mrlCode = $("#mrlCodeS").val();
        //工单号
        var workOrder=$("#workOrder").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getChkTemplateac";
        var data = {
            values: {
                chkBillType: chkBillType,
                mrlCode: mrlCode,
                workOrder:workOrder,
                un: un,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    var evaluation = doT.template($api.dom('#chkTemplateTemp').innerHTML);
                    $api.dom('#chkTemplateList').innerHTML = evaluation(list);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }
    //工单号扫描回车
    $("#workOrder").on('keypress', function(e) {
        console.log(111111111)
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            $("#workOrder").val(tm);
            doSearch();
        }
    });
    //物料号扫描回车
    $("#mrlCodeS").on('keypress', function(e) {
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            $("#mrlCodeS").val(tm);
            doSearch();
        }
    });

    //选则返回函数
    function setChkTemplate(code, name, chkTypeName, mrlCode, mrlName) {
        api.closeWin();
        var nameR = api.pageParam.name;
        api.execScript({
            name: nameR,
            script: 'setChkTemplate("' + code + '","' + name + '","' + chkTypeName + '","' + mrlCode + '","' + mrlName + '")'
        });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
